//
//  KZBaseTabBarController.swift
//  KZSwiftMoudel
//
//  Created by 朱凯 on 2018/6/15.
//  Copyright © 2018年 JooKey. All rights reserved.
//

import UIKit

class KZBaseTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let v1 = KZBaseNavigationController(rootViewController: KZHomeVC())
        let v2 = KZBaseNavigationController(rootViewController: KZSearchRebateVC())
        let v3 = KZBaseNavigationController(rootViewController: KZCheapVC())
        let v4 = KZBaseNavigationController(rootViewController: KZMineVC())
        
        self.viewControllers = [v1, v2, v3, v4]
        
        let images = ["标签栏-首页",
                      "标签栏-搜返利",
                      "标签栏-白菜",
                      "标签栏-我的",
                      ];
        let selectedImages = ["标签栏-首页-sel",
                              "标签栏-搜返利-sel",
                              "标签栏-白菜-sel",
                              "标签栏-我的-sel",
                               ];
        let titles = ["首页",
                      "搜返利",
                      "白菜价",
                      "我的",
                      ];
        
    
        self.tabBar.tintColor = kThemeColor
        for (index, title) in titles.enumerated() {
            let item = UITabBarItem(title: title,
                                    image: UIImage.init(named: images[index]),
                                    selectedImage: UIImage.init(named: selectedImages[index]))
            item.setTitleTextAttributes([NSAttributedStringKey.foregroundColor: kThemeColor],
                                        for: .selected)
            let vc = self.viewControllers![index]
            vc.tabBarItem = item
        }
    }

   
}
